import java.text.*;
import java.util.*;
import java.io.*;

public class ThirdOrderPosteriorProb {

  ThirdOrderForward fwd;

  ThirdOrderBackward bwd;

  private double logprob;

  ThirdOrderPosteriorProb(ThirdOrderForward fwd, ThirdOrderBackward bwd) {
    this.fwd = fwd; 
    this.bwd = bwd;
    logprob = fwd.logprob();
  }

  double posterior(int i, int k) { return Math.exp(fwd.f[i][k] + bwd.b[i][k] - logprob); }

}
